<?php
/* @var $this CategoryController */
/* @var $model Category */

$this->breadcrumbs=array(
	'Categories'=>array('index'),
	'Manage',
);
?>

<div class="page-header">
	<div class="page-title"><h3>Manage Categories</h3></div>
	<div class="buttons">
		<a href="<?php echo $this->createurl('create')?>" class="btn btn-primary">Add Category</a>
	</div>
</div>

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'grid-form',
	'enableAjaxValidation'=>false,
	'action'=>$this->createUrl('grid')
)); ?>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'category-grid',
	'dataProvider'=>$model->search(),
	'filter'=>null,
	'columns'=>array(
		// id
		array('name'=>'id', 'header'=>'ID', 'headerHtmlOptions'=>array('style'=>'width: 50px')),

		// name
		array('name'=>'name', 'header'=>'Name', 'type'=>'raw', 'value'=>'$data->getPathName()'),

		// post_count
		array('name'=>'post_count', 'header'=>'Post', 'headerHtmlOptions'=>array('style'=>'width: 100px')),
		
		// position
		array('class'=>'BootstrapInputColumn', 'header'=>'Position', 'name'=>'position', 'value'=>'$data->position', 'headerHtmlOptions'=>array('style'=>'width: 100px')),

		// actions
		array(
			'header'=>'Actions',
			'class'=>'CButtonColumn',
			'template'=>'{update} {delete}',
			'headerHtmlOptions'=>array('class'=>'span2')
		),
	),
	'itemsCssClass'=>'table table-bordered table-hover',
	'cssFile'=>false,
)); ?>

<button class="hide">submit</button>
<?php $this->endWidget(); // form ?>

<script>
//<![CDATA[
// prevent form submit on enter
$(document).ready(function() {
	$('.filters input').keydown(function(event){
		if(event.keyCode == 13) {
			event.preventDefault();
			return false;
		}
	});
});
//]]>
</script>